#ifndef CS8TABLEVIEW_H
#define CS8TABLEVIEW_H

#include <QTableView>
#include <QStandardItemModel>
#include <QSortFilterProxyModel>
#include "sellermodel.h"

class cs8TableView : public QTableView
{
    Q_OBJECT
public:
    explicit cs8TableView(QWidget *parent = 0);
    void setSellerModel(SellerModel* model);
    void setModel(QAbstractItemModel *model);
    void addEmptySalesRow();

    void clearSalesRows();
    void setSalesPeriod(int value);
    bool loadPosFile(const QString & fileName);
    bool savePosFile(const QString & fileName);
    void setAddAutomaticRow(bool value);

    QSortFilterProxyModel *sellerModel();
signals:
    void totalSumChanged(double value);
    void salesCleared();
    
public slots:
    void removeCurrentRow();
    void calculateTotalSum();

protected:
    bool m_addAutomaticRow;
    int m_salesPeriod;
    QSortFilterProxyModel *m_filteredSellerModel;
    QStandardItemModel *m_salesModel;
    void keyPressEvent (QKeyEvent *event);

protected slots:
    void slotItemChanged(QStandardItem *item);
    
};

#endif // CS8TABLEVIEW_H
